import Vue from "vue"
import Router from "vue-router"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import CommerViews from "@/views/commerViews" //无限极菜单容器
import mainIndex from "@/views/index/mainIndex"

// 不是必须加载的组件使用懒加载
const NotFound = () => import("@/views/page404")
const UnAuth = () => import("@/views/unauth401")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let defaultRouter = [
  {
    path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "Login",
    hidden: true,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: "快乐无边主页",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "home",
        component: mainIndex,
        children: []
      }
    ]
  },
  {
    path: "/err",
    iconCls: "fa fa-dashboard", // 图标样式class
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/401/:msg",
        component: UnAuth,
        name: "401",
        hidden: true,
        children: []
      },
      {
        path: "/404",
        component: NotFound,
        name: "404",
        hidden: true,
        children: []
      }
    ]
  }
]
let addRouter = [
  {
    path: "/sysManager",
    iconCls: "el-icon-edit-outline", // 图标样式class
    name: "系统管理",
    meta: {role: ["superAdmin", "developAdmin", "testAdmin"]},
    component: Layout,
    children: [
      {
        path: "/authManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "权限管理",
        component: CommerViews,
        children: [
          {
            path: "/userManager",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "用户管理",
            //component: () => import('@/views/transfer/transfer'),
            children: []
          }, {
            path: "/rolesManager",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "角色管理",
            //component: AddArticle,
            children: []
          }, {
            path: "/menuManager",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "菜单管理",
            //component: AddArticle,
            children: []
          },
        ]
      },
    ]
  },
  {
    path: "/product",
    iconCls: "el-icon-edit-outline", // 图标样式class
    name: "产品设计",
    meta: {role: ["superAdmin", "developAdmin", "testAdmin", "productAdmin"]},
    component: Layout,
    children: [
      {
        path: "/proInfo",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "产品档案管理",
        component: CommerViews,
        children: [
          {
            path: "/proRegister",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "产品档案登记",
						component: ()=>import('../views/product/ProductRegistration'),
            //component: AddArticle,
            children: []
          },
          {
            path: "/proRegCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "产品档案登记审核",
            component: ()=>import('../views/product/Productaudit'),
            //component: NotFound,
            children: []
          },
          {
            path: "/proFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "产品档案查询",
            	component: ()=>import('../views/product/ProductFiles'),
            //component: AddArticle,
            children: []
          },
        ]
      },
      {
        path: "/productParts",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "产品物料组成设计",
        component: CommerViews,
        children: [
          {
            path: "/proPart",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定物料组成设计单",
            component: ()=>import('../views/product/Material'),
            //component: AddArticle,

            children: []
          }, {
            path: "/proPartCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "物料组成设计单审核",

             component: ()=>import('../views/product/Materialreview'),
            //component: AddArticle,
            children: []
          }, {
            path: "/proPartFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "物料设计单改删查",
            component: ()=>import('../views/product/Materialquery'),
            //component: AddArticle,
            children: []
          }
        ]
      },
    ]
  },
  {
    path: "/storeManager",
    iconCls: "el-icon-edit-outline", // 图标样式class
    name: "仓库管理",
    meta: {role: ["superAdmin", "developAdmin", "testAdmin", "storeAdmin"]},
    component: Layout,
    children: [
      {
        path: "/securityRepManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "安全库存配置管理",
        component: CommerViews,
        children: [
          {
            path: "/makeRep",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定安全库存配置单",
            //component: () => import('@/views/table/maintable'),
            children: []
          }, {
            path: "/makeRepCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "安全库存配置单审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/makeRepFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "安全库存配置单查询",
            //component: AddArticle,
            children: []
          }, {
            path: "/securityRepEdit",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "安全库存配置单变更",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/outStoreRequest",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "出库申请管理",
        component: CommerViews,
        children: [
          {
            path: "/outStoreReq",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库申请登记",
            //component: AddArticle,
            children: []
          }, {
            path: "/outStoreReqCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库申请登记审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/outStoreReqFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库申请查询",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/inStoreRequest",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "入库申请管理",
        component: CommerViews,
        children: [
          {
            path: "/inStoreReq",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库申请登记",
            //component: AddArticle,
            children: []
          }, {
            path: "/inStoreReqCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库申请登记审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/inStoreReqFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库申请查询",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/storeDispatch",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "出入库调度管理",
        component: CommerViews,
        children: [
          {
            path: "/makeInStoreReg",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定入库单",
            //component: AddArticle,
            children: []
          }, {
            path: "/makeOutStoreReg",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定出库单",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/outStoreManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "出库管理",
        component: CommerViews,
        children: [
          {
            path: "/outStore",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库登记",
            //component: AddArticle,
            children: []
          }, {
            path: "/outStoreCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库登记审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/outStoreFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "出库查询",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/inStoreManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "入库管理",
        component: CommerViews,
        children: [
          {
            path: "/inStore",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库登记",
            //component: AddArticle,
            children: []
          }, {
            path: "/inStoreCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库登记审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/inStoreFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "入库查询",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/dynamicRepManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "动态库存管理",
        component: CommerViews,
        children: [
          {
            path: "/dynamicRepFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "动态库存查询",
            //component: AddArticle,
            children: []
          },
        ]
      },
    ]
  },
  {
    path: "/productionManager",
    iconCls: "el-icon-edit-outline", // 图标样式class
    name: "生产管理",
    meta: {role: ["superAdmin", "developAdmin", "testAdmin", "productionAdmin"]},
    component: Layout,
    children: [
      {
        path: "/productionProcesses",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "产品生产工序设计",
        component: CommerViews,
        children: [
          {
            path: "/makeProcess",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定产品生产工序设计单",
            //component: () => import('@/views/production/plan'),
            children: []
          }, {
            path: "/makeProcessCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "产品生产工序设计单审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/ProcessFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "产品生产工序设计单查询",
            //component: AddArticle,
            children: []
          },
        ]
      }, {
        path: "/processPart",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "工序物料设计",
        component: CommerViews,
        children: [
          {
            path: "/makeProcessPart",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定工序物料设计单",
            //component: AddArticle,
            children: []
          }, {
            path: "/processPartCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "工序物料设计单审核",
            //component: AddArticle,
            children: []
          }, {
            path: "/processPartFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "工序物料设计单查询",
            //component: AddArticle,
            children: []
          }
        ]
      }, {
        path: "/productionPlan",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "生产计划管理",
        component: CommerViews,
        children: [
          {
            path: "/makeNewProPlan",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "新发生生产计划登记",
            component: () => import('@/views/production/plan'),
            children: []
          },
          {
            path: "/makeProPlan",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定生产计划",
            //component: AddArticle,
            children: []
          }, {
            path: "/proPlanCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产计划审核",
            component: () => import('@/views/production/plan/checked'),
            children: []
          }, {
            path: "/proPlanFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产计划查询",
            //component: AddArticle,
            children: []
          }
        ]
      }, {
        path: "/proDispatchManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "生产调度管理",
        component: CommerViews,
        children: [
          {
            path: "/makeProDispatch",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "制定生产派工单",
            component: () => import('@/views/production/dispatch'),
            children: []
          }, {
            path: "/proDispatchCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产派工单审核",
            component: () => import('@/views/production/dispatch/checked'),
            children: []
          }, {
            path: "/proDispatchFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产派工单查询",
            //component: AddArticle,
            children: []
          }
        ]
      }, {
        path: "/innerProductionManager",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: "内部生产管理",
        component: CommerViews,
        children: [
          {
            path: "/productionRegister",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产登记",
            //component: AddArticle,
            children: []
          }, {
            path: "/productionRegCheck",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产登记复核",
            //component: AddArticle,
            children: []
          }, {
            path: "/productionFind",
            iconCls: "el-icon-edit-outline", // 图标样式class
            name: "生产查询",
            //component: AddArticle,
            children: []
          }
        ]
      },
    ]
  },
  {
    path: "*",
    redirect: "/404",
    hidden: true,
    children: []
  }
]

export default new Router({
  routes: defaultRouter
})
export {defaultRouter, addRouter}
